package com.company.OfferGuide;

public class 数组中数字出现的次数 {

    public int[] singleNumbers(int[] nums) {

        int sum = 0;
        for (int num : nums) {
            sum ^= num;
        }

        int flag = (-sum) & sum;
        int[] res = new int[2];

        for (int i = 0; i < nums.length; i++) {
            if ((flag & nums[i]) == 0) {
                res[0] ^= nums[i];
            } else {
                res[1] ^= nums[i];
            }
        }
        

        return res;
    }

}
